﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
namespace UI
{
    public partial class open1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["code"] == null)
            {
                Response.Redirect("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxeaaac23155345f7b&redirect_uri=" + Server.UrlEncode("http://www.kdxny84.cn/open1.aspx") + "&response_type=code&scope=snsapi_base&state=1#wechat_redirect");
            }
            else
            {
                WeiXin wx = new WeiXin();
                string result = wx.HttpGet("https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxeaaac23155345f7b&secret=c8ea16461e6d8aba4bc55f417b2a2c81&code=" + Request["code"] + "&grant_type=authorization_code", "");
                string youropenid = wx.ConvertJson(result).openid;
                Response.Redirect("http://www.kdxny84.cn/open2.aspx?youropenid=" + youropenid + "&authorizationappid=wxeaaac23155345f7b");
            }
        }
    }
}